import {Injectable} from '@angular/core';
import {User} from './user';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class UsersService {

  constructor(private httpClient: HttpClient) {
  }

  userInfo(): Observable<User> {

    // 订阅数据
    // this.httpClient.get('http://127.0.0.1:8080/users/100').subscribe(data =>{
    //   console.info(data)
    // })

    return this.httpClient.get<User>('http://127.0.0.1:8080/users/100')
  }

  /**
   * 返回元组数据
   */
  hello(): [number, string] {
    return [100, 'admin']
  }
}
